package com.uam.web.common.thread;


import com.alibaba.fastjson.JSONObject;
import com.uam.common.constant.CST;
import com.uam.utils.HttpUtils;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.concurrent.CountDownLatch;

/**
 * 航线导出功能
 *
 * @author heguanglong
 * @date 2023/6/13
 */
@Slf4j
public class RouteExportThread implements Runnable {

    private CountDownLatch countDownLatch;

    private Long taskId;

    List<JSONObject> taskVOS;

    public RouteExportThread(CountDownLatch countDownLatch, Long taskId, List<JSONObject> taskVOS) {
        this.countDownLatch = countDownLatch;
        this.taskId = taskId;
        this.taskVOS = taskVOS;

    }

    @Override
    public void run() {
        try {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("task_id", taskId);
            JSONObject jo = HttpUtils.get(CST.URL + "/uam/route/track/detail", jsonObject);
            if (jo != null) {
                taskVOS.add(jo);
            }
        } catch (Exception e) {
            log.error("导出航线获取数据错误！ ", e);
        }
        countDownLatch.countDown();
    }

}

